package third;

import com.alibaba.fastjson.JSON;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * \* User: MeiZhongHao
 * \* Date: 2019-04-12
 * \* Time: 09:37
 * \* Description:
 * \
 */
public class BaiduService {

    public void creditScore(BaiduParam baiduParam) {
        HttpParam param = new AbstractBaiduService(){
            @Override
            public HttpParam paramMapping(AbstractParam object, AppConf third, MultipartFile file) {
                HttpParam param = new HttpParam();
                Map<String, String> map = new HashMap<>();
                BaiduParam baidu = (BaiduParam) object;
                String datetime = String.valueOf(System.currentTimeMillis());
                map.put("sp_no", "1300121327");
                map.put("service_id", "1007");
                map.put("reqid", UUID.randomUUID().toString());
                map.put("name", baidu.getName());
                map.put("identity", baidu.getIdCard());
                map.put("phone", baidu.getMobile());
                map.put("datetime", datetime);
                map.put("sign_type", "1");
                map.put("models", "general_preA");
                param.setUrlParams(map);
                param.setThirdUrl("https://jrws.baidu.com/risk/api/info/search");
                return param;
            }
        }.request(baiduParam, null, null);
        System.out.println(JSON.toJSONString(param.getRespData()));
    }

    public static void main(String[] args) {
        BaiduParam param = new BaiduParam();
        param.setIdCard("433122198403294537");
        param.setMobile("15158519253");
        param.setName("李长春");
        new BaiduService().creditScore(param);
    }

}